<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<script>
    var flag=0;
    $(document).ready(function () {
        selectCopiedOrders();//查询转抄
        context.init({preventDoubleContext: false});
        $(".center-main").each(function () {
            addContext($(this).attr("id"),$(this).attr("bedId"),$(this).attr("bedNo"),$(this).attr("visitId"),$(this).attr("patientId"),$(this).attr("newbornFlg"));
        });
        $(".center-main").click(function(){
            $(".center-card").removeClass("selected");
            $(this).find(".center-card").addClass("selected");
        });
        /**
         * 右键病人列表事件
         */
        function addContext(divId,bedId,bedNo,visitId,patientId,newbornFlg) {
            if (visitId == '' || visitId == null) {
                context.attach("#" + divId, [
                    {text: '病人流转',
                        subMenu: [
                            {text: '移入', action: function (e) {
                                layer.open({
                                    type: 2,
                                    title: '移入病区',
                                    skin: 'layui-layer-rim', //样式类名
                                    shadeClose: true,
                                    shade: 0.5,
                                    area: ['62%', '80%'],
                                    content:'${ctx}/nurse/wardCirculation/turnInIndexWard?bedRecId='+bedId
                                });
                            }},
                            <%--{text: '移出', action: function (e) {--%>
<%--layer.open({--%>
<%--type: 2,--%>
<%--title: '移出病区',--%>
<%--skin: 'layui-layer-rim', //样式类名--%>
<%--shadeClose: true,--%>
<%--shade: 0.5,--%>
<%--area: ['62%', '80%'],--%>
<%--content: '${ctx}/nurse/wardCirculation/turnOutWardIndex?bedRecId='+bedId--%>
<%--});--%>
<%--}},--%>
                            {text: '出院', action: function (e) {
                                layer.open({
                                    type: 2,
                                    title: '出院',
                                    skin: 'layui-layer-rim', //样式类名
                                    shadeClose: true,
                                    shade: 0.5,
                                    area: ['62%', '80%'],
                                    content: '${ctx}/nurse/wardCirculation/leaveHospIndex?bedRecId='+bedId
                                });
                            }},
                            {text: '取消',
                                subMenu: [
                                    {text: '取消移入', action: function (e) {
                                        layer.open({
                                            type: 2,
                                            title: '取消移入病区',
                                            skin: 'layui-layer-rim', //样式类名
                                            shadeClose: true,
                                            shade: 0.5,
                                            area: ['62%', '80%'],
                                            content: '${ctx}/nurse/wardCirculation/cancelTurnInWard?bedRecId='+bedId
                                        });
                                    }},
                                    {text: '取消移出', action: function (e) {
                                        layer.open({
                                            type: 2,
                                            title: '取消移出病区',
                                            skin: 'layui-layer-rim', //样式类名
                                            shadeClose: true,
                                            shade: 0.5,
                                            area: ['62%', '80%'],
                                            content: '${ctx}/nurse/wardCirculation/cancelTurnOutWardIndex'
                                        });
                                    }},
                                    {text: '取消出院', action: function (e) {
                                        layer.open({
                                            type: 2,
                                            title: '取消出院',
                                            skin: 'layui-layer-rim', //样式类名
                                            shadeClose: true,
                                            shade: 0.5,
                                            area: ['62%', '80%'],
                                            content: '${ctx}/nurse/wardCirculation/cancelLeaveHospIndex?bedRecId='+bedId
                                        });
                                    }}
                                ]
                            }
                        ]
                    }
                ]);
            } else {
                if (newbornFlg&&(newbornFlg==1||newbornFlg=='1')){
                    context.attach("#" + divId, [
                        {text: '护理', action: function (e) {
                            loadDiv('nurseIndexDiv', '${ctx}/nurse/nurseTempInfo/index?badNo='+bedNo+'&patientId='+patientId+'&visitId='+visitId+"&type="+newbornFlg)
                        }},
                        {text: '医嘱信息', action: function (e) {
                            loadDiv('nurseIndexDiv', '${ctx}/orders/orders/findNurseOrders?pageFlag=1&patientId='+patientId+'&visitId='+visitId)
                        }},
                        {text: '费用补录', action: function (e) {
                            loadDiv('nurseIndexDiv', '${ctx}/orders/orders/feeOper?patientId='+patientId+'&visitId='+visitId)
                        }},
                        {text: '退费', action: function (e) {
                            loadDiv('nurseIndexDiv', '${ctx}/nurse/nurseReturnFeeApply/returnFee?patientId='+patientId+'&id='+visitId)
                        }},
                        {text:'执行单',action:function(e){
                            loadDiv('nurseIndexDiv','${ctx}/nurse/performSingle?visitId='+visitId+'&type=druglist');
                        }},
                        {text:'费用核对',action:function(e){
                            loadDiv('nurseIndexDiv','${ctx}/nurse/checkCosts?visitId='+visitId);
                        }},
                        {text:'患者信息',action:function(e){
                            layer.open({
                                type: 2,
                                title: '基本信息',
                                skin: 'layui-layer-rim', //样式类名
                                shadeClose: true,
                                shade: 0.5,
                                area: ['60%', '80%'],
                                content: '${ctx}/nurse/patientBasicInfo?visitId='+visitId
                            });
                        }}
                    ]);
                }else {
                    context.attach("#" + divId, [
                        {text: '病人流转',
                            subMenu: [
                                {text: '移出', action: function (e) {
                                    layer.open({
                                        type: 2,
                                        title: '移出病区',
                                        skin: 'layui-layer-rim', //样式类名
                                        shadeClose: true,
                                        shade: 0.5,
                                        area: ['62%', '80%'],
                                        content: '${ctx}/nurse/wardCirculation/turnOutWardIndex?bedRecId='+bedId+'&patVisitId='+visitId+'&patientId='+patientId
                                    });
                                }},
                                {text: '出院', action: function (e) {
                                    layer.open({
                                        type: 2,
                                        title: '出院',
                                        skin: 'layui-layer-rim', //样式类名
                                        shadeClose: true,
                                        shade: 0.5,
                                        area: ['62%', '80%'],
                                        content: '${ctx}/nurse/wardCirculation/leaveHospIndex?bedRecId='+bedId+'&patVisitId='+visitId+'&patientId='+patientId
                                    });
                                }},

                                {text: '取消',
                                    subMenu: [
                                        {text: '取消移入', action: function (e) {
                                            layer.open({
                                                type: 2,
                                                title: '取消移入病区',
                                                skin: 'layui-layer-rim', //样式类名
                                                shadeClose: true,
                                                shade: 0.5,
                                                area: ['62%', '80%'],
                                                content: '${ctx}/nurse/wardCirculation/cancelTurnInWard?bedRecId='+bedId+'&patVisitId='+visitId+'&patientId='+patientId
                                            });
                                        }},
                                        {text: '取消移出', action: function (e) {
                                            layer.open({
                                                type: 2,
                                                title: '取消移出病区',
                                                skin: 'layui-layer-rim', //样式类名
                                                shadeClose: true,
                                                shade: 0.5,
                                                area: ['62%', '80%'],
                                                content: '${ctx}/nurse/wardCirculation/cancelTurnOutWardIndex'
                                            });
                                        }},
                                        {text: '取消出院', action: function (e) {
                                            layer.open({
                                                type: 2,
                                                title: '取消出院',
                                                skin: 'layui-layer-rim', //样式类名
                                                shadeClose: true,
                                                shade: 0.5,
                                                area: ['62%', '80%'],
                                                content: '${ctx}/nurse/wardCirculation/cancelLeaveHospIndex?bedRecId='+bedId
                                            })
                                        }}
                                    ]
                                }
                            ]
                        },
                        {text: '护理', action: function (e) {
                            loadDiv('nurseIndexDiv', '${ctx}/nurse/nurseTempInfo/index?badNo='+bedNo+'&patientId='+patientId+'&visitId='+visitId+"&type="+newbornFlg)
                        }},
                        {text: '医嘱信息', action: function (e) {
                            loadDiv('nurseIndexDiv', '${ctx}/orders/orders/findNurseOrders?pageFlag=1&patientId='+patientId+'&visitId='+visitId)
                        }},
                        {text: '费用补录', action: function (e) {
                            loadDiv('nurseIndexDiv', '${ctx}/orders/orders/feeOper?patientId='+patientId+'&visitId='+visitId)
                        }},
                        {text: '退费', action: function (e) {
                            loadDiv('nurseIndexDiv', '${ctx}/nurse/nurseReturnFeeApply/returnFee?patientId='+patientId+'&id='+visitId)
                        }},
                        {text:'执行单',action:function(e){
                            loadDiv('nurseIndexDiv','${ctx}/nurse/performSingle?visitId='+visitId+'&type=druglist');
                        }},
                        {text:'费用核对',action:function(e){
                            loadDiv('nurseIndexDiv','${ctx}/nurse/checkCosts?visitId='+visitId);
                        }},
                        {text:'新生儿登记',action:function(e){
                            loadDiv('nurseIndexDiv','${ctx}/nurse/newbornRec/index');
                        }},
                        {text: '新生儿住院登记', action: function (e) {
                            loadDiv('nurseIndexDiv', '${ctx}/nurse/newbornRec/inHosReg');
                        }},
                        {text:'患者信息',action:function(e){
                            layer.open({
                                type: 2,
                                title: '基本信息',
                                skin: 'layui-layer-rim', //样式类名
                                shadeClose: true,
                                shade: 0.5,
                                area: ['60%', '80%'],
                                content: '${ctx}/nurse/patientBasicInfo?visitId='+visitId
                            });
                        }}
                    ]);
                }

            }

        }
    })

    function refesh(){
        loadDiv('nurseIndexDiv', '${ctx}/nurse/index');
    }
    /**
    * 查询转抄医嘱
     */
    function selectCopiedOrders(){
        $.ajax({
            type:'get',
            url:'${ctx}/orders/orders/selectCopiedOrders',
            dataType:'json',
            cache:false,
            success:function(data){
                if(data.code=='success'){
                    register = layer.open({
                        title: '转抄医嘱',
                        type: 1,
                        area: ['20%', '20%'],
                        content: data.data,
                        btn: ['确定', '取消'],
                        yes: function (index, layero) {
                            layer.close(register);
                            loadDiv('nurseIndexDiv','${ctx}/orders/orders/findNurseOrders?pageFlag=0');
                        },
                        end: function () {

                        }
                    });
                }
            },
            error:function(data){
                toastr.error("网络错误！");
            }
        })
    }


</script>
<div id="nurseIndexDiv" class="height-100">
    <div class="content-wrap" id="bedList">
        <div class="wrapper"  >
            <ul class="nav nav-tabs">
                <li class="active">
                    <a href="#">床位列表</a>
                </li>
            </ul>
            <section class="panel panel-default">
                <div class="panel-body">
                    <c:forEach items="${list}" var="bedRec" varStatus="coun">
                        <div class="center-main" ondblclick="loadDiv('nurseIndexDiv', '${ctx}/orders/orders/findNurseOrders?pageFlag=1&patientId=${bedRec.patVisit.patientId}&visitId=${bedRec.patVisit.id}')" id="centerId${coun.count}" bedId="${bedRec.id}" bedno="${bedRec.bedNo}" visitId="${bedRec.patVisit.id}" patientId="${bedRec.patVisit.patientId}" newbornFlg="${bedRec.patVisit.patVisitIndex.newbornFlg}">
                            <div class="center-card">
                                <div class="center-card-top">
                                    <div class="center-card-bed">${bedRec.bedNo}</div>
                                    <div class="center-card-miss">姓名：${bedRec.patVisit.patVisitIndex.name}
                                    </div>,
                                </div>
                                <div class="boby">
                                    <c:choose>
                                        <c:when test="${bedRec.patVisit.patVisitIndex.sex==2}">
                                            <img src="${ctxStatic}/images/boby.png">
                                        </c:when>
                                        <c:when test="${bedRec.patVisit.patVisitIndex.sex==1}">
                                            <img src="${ctxStatic}/images/body-n.png">
                                        </c:when>
                                        <c:otherwise></c:otherwise>
                                    </c:choose>
                                </div>
                                <div class="center-card-bottom">
                                    <ul>
                                        <li><label>住院号：</label><span>${bedRec.patVisit.visitNo}</span></li>
                                        <c:choose>
                                            <c:when test="${bedRec.checkOrdersNum>0}">
                                                <li>
                                                    <label>年龄：</label>
                                                    <span>${bedRec.patVisit.patVisitIndex.age}岁;<font color="red">未校对${bedRec.checkOrdersNum}</font></span></li>
                                            </c:when>
                                            <c:otherwise>
                                                <li>
                                                    <label>年龄：</label>
                                                    <span>${bedRec.patVisit.patVisitIndex.age}岁</span></li>
                                            </c:otherwise>
                                        </c:choose>
                                        <li><label>病情：</label><c:if test="${bedRec.patVisit.situationType eq '1'}"><span style="color: red">危</span></c:if><c:if test="${bedRec.patVisit.situationType eq '2'}"><span style="color:yellow">重</span></c:if><c:if test="${bedRec.patVisit.situationType eq '3'}"><span>一般</span></c:if></li>
                                        <li><label>护理等级：</label>
                                            <c:choose>
                                            <c:when test="${bedRec.patVisit.nursingClass eq '6'}">
                                            <span style="color: red">病危护理</span>
                                            </c:when>
                                            <c:when test="${bedRec.patVisit.nursingClass eq '5'}">
                                            <span style="color:yellow">病重护理</span>
                                            </c:when>
                                                <c:otherwise>${fns:getDictLabel(bedRec.patVisit.nursingClass,'NURSING_CLASS_DICT' , '')}</c:otherwise>
                                            </c:choose>
                                        <li><label>诊断：</label><span>${bedRec.patVisit.diagnosis}</span></li>
                                        <li><label>费别：</label><span>${fns:getDictLabel(bedRec.patVisit.patVisitIndex.chargeType,'CHARGE_TYPE_DICT' ,'' )}</span></li>
                                        <li><label>入院时间：</label><span><fmt:formatDate
                                                value="${bedRec.patVisit.admissionDate}" pattern="yyyy-MM-dd"/></span></li>
                                        <li><label>主治医生：</label><span>${bedRec.patVisit.doctorInChargeEt.name}</span></li>
                                        <li><label>预交金余额：</label><span>${bedRec.patVisit.prepayments}</span></li>


                                    </ul>
                                </div>
                            </div>
                        </div>
                    </c:forEach>
                </div>
            </section>
        </div>
    </div>
</div>

<section class="main-content">
    <footer class="bg-white navbar-fixed-bottom" style="z-index: 9999;height: 50px">
        <ul class="nav navbar-nav">
            <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                    医嘱信息<b class="caret"></b>
                </a>
                <ul class="dropdown-menu">
                    <li><a href="#" onclick="loadDiv('nurseIndexDiv','${ctx}/orders/orders/findNurseOrders?pageFlag=0')">医嘱转抄</a></li>
                    <%--<li class="divider"></li>
                    <li><a href="#" onclick="loadDiv('nurseIndexDiv','${ctx}/nurse/bedRec/formList')">床位维护</a></li>--%>
                    <li class="divider"></li>
                    <li><a href="#" onclick="loadDiv('nurseIndexDiv','${ctx}/nurse/examApply')">检查单</a></li>
                    <li class="divider"></li>
                    <li><a href="#" onclick="loadDiv('nurseIndexDiv','${ctx}/nurse/labApply')">检验单</a></li>
                    <li class="divider"></li>
                    <li><a href="#" onclick="loadDiv('nurseIndexDiv','${ctx}/doctor/preDischgedPats/nurseIndex')">出院通知单</a></li>
                    <li class="divider"></li>
                    <%--<li><a href="#" onclick="loadDiv('nurseIndexDiv','${ctx}/nurse/newbornRec/apgarIndex')">新生儿apgar评分记录</a></li>--%>
                    <li><a href="#" onclick="loadDiv('nurseIndexDiv','${ctx}/nurse/wardCodeIndex')">病区工作量查询</a></li>
                    <li class="divider"></li>
                    <li><a href="#" onclick="loadDiv('nurseIndexDiv','${ctx}/nurse/wardCodesIndex')">护理工作量查询</a></li>
                </ul>
            </li>
            <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown" >
                    摆药信息<b class="caret"></b>
                </a>
                <ul class="dropdown-menu">
                    <li><a href="#" onclick="loadDiv('nurseIndexDiv','${ctx}/orders/orders/dispIndex?type=1')">预摆药查询</a></li>
                  <%--  <li class="divider"></li>
                    <li><a href="#" onclick="loadDiv('nurseIndexDiv','${ctx}/nurse/prescDurgClass')">摆药单查询(药品)</a></li>--%>
                    <li class="divider"></li>
                    <li><a href="#" onclick="loadDiv('nurseIndexDiv','${ctx}/nurse/prescPatDrug?type=1')">摆药单查询</a></li>
                </ul>
            </li>
            <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                    综合查询<b class="caret"></b>
                </a>
                <ul class="dropdown-menu">
                    <li><a href="#" onclick="loadDiv('nurseIndexDiv','${ctx}/doctor/patVisit/patVisitInfo?inFlag=0')">住院病人</a></li>
                    <li class="divider"></li>
                    <li><a href="#" onclick="loadDiv('nurseIndexDiv','${ctx}/doctor/patVisit/patVisitInfo?inFlag=1&deptFlag=2&wardFlag=2')">出院病人</a></li>
                    <li class="divider"></li>
                    <li><a href="#" onclick="loadDiv('nurseIndexDiv','${ctx}/nurse/drugSearch')">处方查询</a></li>
                    <li class="divider"></li>
                    <li><a href="#" onclick="loadDiv('nurseIndexDiv','${ctx}/nurse/unFinishedItems')">出院未做项目查询</a></li>
                </ul>
            </li>
            <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                    综合打印<b class="caret"></b>
                </a>
                <ul class="dropdown-menu">
<%--
                    <li><a href="#" onclick="loadDiv('nurseIndexDiv','${ctx}/nurse/paymentsSearch')">预交金欠费查询</a></li>
--%>
                    <li class="divider"></li>
                    <li><a href="#" onclick="loadDiv('nurseIndexDiv','${ctx}/doctor/patVisit/bedCardList')">住院患者卡片</a></li>
                    <li class="divider"></li>
                    <li><a href="#"  onclick="loadDiv('nurseIndexDiv','${ctx}/orders/orders/findOrdersBottleLabel')">医嘱瓶签</a></li>
                    <li class="divider"></li>
                    <li><a href="#" onclick="loadDiv('nurseIndexDiv','${ctx}/nurse/dayOfList')">一日清单</a></li>
                    <li class="divider"></li>
                    <li><a href="#" onclick="loadDiv('nurseIndexDiv','${ctx}/finance/patPrepayment/waitPrepayList')">催补预交金</a></li>
                    <li class="divider"></li>
                    <li><a href="#" onclick="loadDiv('nurseIndexDiv','${ctx}/doctor/prescriptionApply/prescriptionVisit')">处方汇总</a></li>
                </ul>
            </li>
            <li class="dropdown">
                <a href="#" onclick="refesh()" >床位刷新</a></li>
            </li>
        </ul>
    </footer>
</section>